package com.bytz.modules.cms.echop.model;

import com.bytz.common.exception.BytzBootException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.File;

@Getter
@Setter
public class CreateDocumentByFileRequest {

    @ApiModelProperty("附件")
    private File file;

    @ApiModelProperty("附件")
    private String title = "附件-CMS审批记录";

    @ApiModelProperty("文件后缀")
    private String fileType = "xlsx";

    public CreateDocumentByFileRequest(File file) {
        this.file = file;
    }

    public void deleteFile() {
        if (file == null) {
            return;
        }
        System.gc();
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            throw new BytzBootException(e);
        }
        boolean ignore = file.delete();
    }
}
